#include "sigmask.h"
#include "CriticalCtrl.h"

static unsigned int Critcal_Counter = 0;


static void lock_interrupt()
{
    pthread_sigmask(SIG_BLOCK, &all_sig_set, NULL);
}
static void unlock_interrupt()
{
    pthread_sigmask(SIG_UNBLOCK, &all_sig_set, NULL);
}

//one pair lock
void entry_Critical_Lock()
{
    if (Critcal_Counter == 0)
    {
        lock_interrupt();
    }

    Critcal_Counter++;
}


void exit_Critical_unlock()
{
    Critcal_Counter--;

    if (Critcal_Counter == 0)
    {
        unlock_interrupt();
    }
}
